// pages/config/editModal/editModal.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    currentEditCourseConfig: Object,
    courseTitleRange: Array,
    username: String,
    courseConfigs:Array,
    courseDetails:Array,
    weeks:Array,
    showEdit:{
      type:Boolean,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {

    // 实际不起作用, 我想想能不能定义函数,就可以直接掉了,然后然后true就是验证通过
    rules: {
      name: {
        require: {
          value: true,
          errMsg: ""
        },
        re: {
          value: '^[\u4e00-\u9fa5]{0,}$',
          errMsg: "用户名只能是中文",
        },
      }
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    hideModalEdit(){
      this.setData({showEdit:false})
    },
    editCourseConfigEnd({ detail }: { detail: IChaoXinConfigFormDetail }) {
      this.data.courseConfigs[this.data.currentEditCourseConfig.courseConfigIdx] = {
        course: this.data.courseDetails[detail.course as any],
        courseIdx: detail.course,
        day: detail.week,
        endTime: detail.endTime,
        startTime: detail.startTime,
        courseConfigIdx: this.data.currentEditCourseConfig.courseConfigIdx,
      }
      this.setData({ courseConfigs: this.data.courseConfigs })
      this.triggerEvent("edit",this.data.courseConfigs,{bubbles:true,composed:true})
      this.hideModalEdit()
    },
  },
})
